﻿using System.Data;
using System.Data.EntityClient;
using System.Data.SqlClient;
using WmsService.Factory;

namespace WmsService.DataAccess
{
    public class DataQuerier
    {
        public static DataTable GetDataTable(string sql)
        {
            var ctx = ContextFactory.Create();
            var connectionString =
                ((EntityConnection) ctx.Connection).StoreConnection.ConnectionString;
            var sqlConnection = new SqlConnection(connectionString);
            var adapter = new SqlDataAdapter(new SqlCommand(sql, sqlConnection));
            var dt = new DataTable();
            adapter.Fill(dt);
            return dt;
        }
    }
}